package bb.lanxing.activity.discover;

import android.os.Bundle;
import android.widget.ImageView;

import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;

import bb.lanxing.R;
import bb.lanxing.activity.base.BaseActivity;
import bb.lanxing.adapter.discover.PlanTabAdapter;
import bb.lanxing.model.database.BbsType;

public class PlanListActivity extends BaseActivity {
    private static final int[] types = {R.string.cycling, R.string.running, R.string.walking,
            R.string.skiing, R.string.swimming, R.string.training, R.string.indoor_cycling,
            R.string.device_biketrainer_title, R.string.ftms_rower, R.string.ftms_crosstrainer,
            R.string.other_sport};

    private TabLayout tabLayout;
    private ViewPager viewPager;
    private PlanTabAdapter bbsTabAdapter;
    private final ArrayList<BbsType> tabList = new ArrayList<>();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_plan_list);

        ImageView back = findViewById(R.id.back);
        back.setOnClickListener(v -> onBackPressed());

        tabLayout = findViewById(R.id.tabLayout);
        viewPager = findViewById(R.id.pager);

        for (int i = 0; i < types.length; i++) {
            tabList.add(new BbsType(getString(types[i]), i));
        }
        bbsTabAdapter = new PlanTabAdapter(getSupportFragmentManager(), tabList);
        viewPager.setAdapter(bbsTabAdapter);
        tabLayout.setupWithViewPager(viewPager);
    }
}